<?php

namespace app\controller\command;

use app\result\PushResult;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;

class PushBill extends Command
{
    protected function configure()
    {
        $this->setName('push_bill')
            ->addOption('type', null, Option::VALUE_OPTIONAL, '时间类型day|week|month|year')
            ->setDescription('生成账单推送');
    }

    protected function execute(Input $input, Output $output)
    {

        if ($input->hasOption('type')) {
            $type = $input->getOption('type');
        } else {
            $type = 'day';
        }

        $output->writeln("当前时间类型：" . $type . '');
        $res = (new PushResult())->push_bill($type);

        $output->writeln($res['msg']);
    }
}
